#ifndef DictHashTab_First
#define DictHashTab_First
#ifdef __GNUG__
#pragma interface
#endif

#include "HashTable.h"

//---- Assoc -------------------------------------------------------------------

struct Assoc {
	Object *key, *val;
};

//---- DictHashTab -------------------------------------------------------------

class DictHashTab : public HashTable {
public:
	MetaDef(DictHashTab);
	DictHashTab(int initCap, pEqualFunc eq, pHashFunc hash, int *size= 0);
	~DictHashTab();
	void Empty(int newCapacity);

	virtual void *AddAt(void *value, void *key, bool replace);
	virtual void *RemoveKey(void *key, void **value, EqualType equal);
	virtual void *AtKey(void *key, EqualType equal);
	virtual void *FindKey(void *key, void **value, EqualType equal);

	virtual void *ValueAt(int i);
protected:
	//---- table primitives
	void *KeyAt(int i);
	void SetKeyAt(void *key, int i);
	void NullAt(int i);
	void Swap(int i, int j);
	virtual void SetValueAt(void *value, int slot);

	void DoRehash(HashTable *ht);
	HashTable *MakeNew(int initCapacity);
	void Assign(HashTable *ht);

protected:
	Assoc *tab;
};

#endif

